/**
 * Copyright (c) iwindplus Technologies Co., Ltd.2024-2030, All rights reserved.
 */

package com.iwindplus.boot.domain.dto;

import com.iwindplus.boot.domain.constant.CommonConstant;
import com.iwindplus.boot.domain.enums.OperateTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.experimental.SuperBuilder;
import net.dreamlu.mica.core.utils.StringUtil;
import org.slf4j.MDC;

/**
 * 消息数据传输对象.
 *
 * @param <T> 泛型
 * @author zengdegui
 * @since 2023/10/15 11:29
 */
@Schema(description = "消息数据传输对象")
@Data
@SuperBuilder
@AllArgsConstructor
public class MessageDTO<T> implements Serializable {
    /**
     * 任务Id.
     */
    @Schema(description = "任务Id")
    private String taskId;

    /**
     * 跟踪唯一标识.
     */
    @Schema(description = "跟踪唯一标识")
    private String traceId;

    /**
     * 操作类型.
     */
    @Schema(description = "操作类型")
    private OperateTypeEnum operateType;

    /**
     * 数据.
     */
    @Schema(description = "数据")
    private T data;

    /**
     * 构造方法.
     */
    public MessageDTO() {
        this.taskId = StringUtil.getUUID();
        this.traceId = MDC.get(CommonConstant.TraceConstant.TRACE_ID);
    }
}
